<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('联登用户列表')" />
    <th:block th:include="include :: select2-css" />

</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>产品名称：</label>
                                <input type="text" name="productName" />
                            </li>
                            <li>
                                <label>状态：</label>
                                <select class="form-control"  name="status">
                                    <option value="">所有</option>
                                    <option value="INIT">撞库成功</option>
                                    <option value="FAILED">撞库失败</option>
                                    <option value="SUCCESS">联登成功</option>
                                    <option value="ERROR">联登失败</option>
                                </select>
                            </li>
                            <li>
                                <label>截止日期：</label>
                                <input type="text" name="showDate" id="showDate" />
                            </li>
                            <li>
                                <label>创建日期：</label>
                                <input type="text" name="createTime" id="create_time" />
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

<!--            <div class="btn-group-sm" id="toolbar" role="group">-->
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="product:union:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="product:union:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="product:union:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="product:union:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
<!--            </div>-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('product:union:edit')}]];
        var removeFlag = [[${@permission.hasPermi('product:union:remove')}]];
        var prefix = ctx + "product/union";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "联登用户",
                columns: [
                //     {
                //     checkbox: true
                // },
                // {
                //     field: 'productId',
                //     title: '产品ID'
                // },
                    {
                        field: 'productName',
                        title: '产品名称'
                    },
                {
                    field: 'userIdStr',
                    title: '用户ID'
                },

                {
                    field: 'productUrl',
                    title: '产品地址',
                    formatter: function (value, row, index) {
                        return row.productUrl == undefined?'-':'<a href="'+row.productUrl+'" target="_blank">预览</a>';
                    }
                },
                // {
                //     field: 'status',
                //     title: '状态'
                // },
                // {
                //     field: 'type',
                //     title: '类型'
                // },
                    {
                        field: 'status',
                        title: '状态',
                        formatter: function (value, row, index) {

                            var result = '';
                            if(row.status == 'INIT'){
                                result = '<span class="badge badge-success">撞库成功</span>';
                            }else if(row.status == 'FAILED'){
                                result = '<span class="badge badge-warning">撞库失败</span>';
                            }else if(row.status == 'SUCCESS'){
                                result = '<span class="badge badge-info">联登成功</span>';
                            }else if(row.status == 'ERROR'){
                                result = '<span class="badge badge-danger">联登失败</span>';
                            }
                            return result;
                        }
                    },
                    {
                        field: 'type',
                        title: '类型'
                    },
                    {
                        field: 'showDate',
                        title: '展示日期'
                    },
                    {
                        field: 'createTime',
                        title: '创建时间'
                    },
                // ,
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.status == 'INIT'){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick=""><i class="fa fa-edit"></i>\手动联登</a> ');
                        }
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.productId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }
                ]
            };
            $.table.init(options);
        });

        layui.use('laydate', function(){
            var laydate = layui.laydate;

            laydate.render({
                elem: '#showDate',
                type: 'date'
            });

        });
    </script>
</body>
</html>